<script>
	import config from './config'
	import store from '@/store'
	import {
		getToken
	} from '@/common/auth'
	import * as SSKEYS from '@/common/session-storage-keys'

	export default {
		onLaunch: function() {
			this.initApp()
		},
        // onShow() {
        //      this.$store.dispatch("initLogin")
        // },
        // onHide() {
        //     this.$store.dispatch("closeSocket")
        // },
		methods: {
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				// 检查用户登录状态
				//#ifdef H5
				uni.setStorageSync(SSKEYS.ACCOUNT_APPLICATION_PLATFORM_KEY, 'H5')
				//#endif

				// #ifdef APP-PLUS
				uni.setStorageSync(SSKEYS.ACCOUNT_APPLICATION_PLATFORM_KEY, 'APP-PLUS')
				// #endif

				// #ifdef MP-WEIXIN
				uni.setStorageSync(SSKEYS.ACCOUNT_APPLICATION_PLATFORM_KEY, 'MP-WEIXIN')
				// #endif
			},
			initConfig() {
				this.globalData.config = config
			},
			checkLogin() {
				if (!getToken()) {
					this.$tab.reLaunch('/pages/login')
				}
			}
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import '@/static/scss/index.scss';
    @import './common/free.css';
</style>
